package com.cat.dataStructure02;

/**
 * @author 曲大人的喵
 * @description https://leetcode.cn/problems/clumsy-factorial/
 * @create 2025/10/26 18:57
 * @since JDK17
 */

public class Solution65 {
    public int clumsy(int n) {
        if (n <= 2) {
            return n;
        }
        if (n == 3) {
            return 6;
        }
        int ans = n * (n - 1) / (n - 2) + n - 3;
        n -= 4;
        while (n >= 4) {
            ans -= n * (n - 1) / (n - 2) - (n - 3);
            n -= 4;
        }

        return ans - clumsy(n);
    }
}
